package com.anXin.user.controller;

import com.anXin.model.common.dtos.ResponseResult;
import com.anXin.model.user.pojos.Oldman;
import com.anXin.user.service.OldmanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "管理老人接口" )
@RestController
@RequestMapping("/oldman")
public class OldmanController {
    @Resource
    private OldmanService oldmanService;


    @ApiOperation("绑定老人")
    @PostMapping("/add")
    private ResponseResult addOld(@RequestBody Oldman oldman){
        return oldmanService.addOld(oldman);
    }
    @ApiOperation("获取绑定老人列表")
    @GetMapping("/list")
    private ResponseResult getOldList(){
        return oldmanService.getOldList();
    }

    @ApiOperation("解除老人绑定关系")
    @DeleteMapping("/delete/{id}")
    private ResponseResult delete(@PathVariable("id") Long id){
        return oldmanService.delete(id);
    }

    @ApiOperation("更新绑定的老人信息")
    @PutMapping("/update")
    private ResponseResult updateOld(@RequestBody Oldman oldman){
        return oldmanService.updateOld(oldman);
    }

    @ApiOperation("获取针对该老人的膳食食谱")
    @GetMapping("/cookbook/{id}")
    private ResponseResult cookbook(@PathVariable("id") Long id) throws Exception {
        return oldmanService.cookbook(id);
    }

    @ApiOperation("获取针对该老人的照顾计划")
    @GetMapping("/carePlan/{id}")
    private ResponseResult carePlan(@PathVariable("id") Long id) throws Exception {
        return oldmanService.carePlan(id);
    }

    @ApiOperation("获取该老人的信息")
    @GetMapping("/oldmanInfo/{id}")
    public ResponseResult userInfo(@PathVariable("id")  Long id) {
        return oldmanService.oldmanInfo(id);
    }
}
